﻿using Budget.Model;
using Microsoft.EntityFrameworkCore;

namespace Budget.Dao.AdminDao
{
    public class AdminDao :DbContext
    {
     
        public Admin GetAdmin(string account)
        {

            //Admin admin = Queryable<Admin>().Where(i => i.Account.Equals(account)).Single();
            Admin admin = Query<Admin>().FirstOrDefaultAsync(i => i.Account == account).Result;
            //Admin admin = new Admin()
            //{
            //    Account = "admin",
            //    Password = "1234",
            //    Id = "1",
            //    Name = "管理员"
            //};
            return admin; 
        }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            //配置mariadb连接字符串
            optionsBuilder.UseMySql("server=10.0.2.25;database=budget;uid =root;pwd=1234.abcd;");
        }

        public DbSet<Admin> Admins { get; set; }
    }
}
